-- target  目标  
--TARGET_TEAM_FUBEN_DAILY_LOW = 1
--TARGET_TEAM_FUBEN_DAILY_HIGH = 2 
--TARGET_TEAM_FUBEN_WEEKLY_LOW = 3 
--TARGET_TEAM_FUBEN_WEEKLY_HIGH = 4 
TARGET_CHANGE_NAME = 10001
TARGET_FRIEND = 10002
TARGET_GUILD = 10003
TARGET_FREE_MOVE = 10004
TARGET_MAIN_QUEST = 10005
--TARGET_TEAM_SHILIAN = 51 


-- condition 条件
CONDITION_NOT_LOGIN_MAP = "NotLoginMap" 
CONDITION_ALREADY_LOGIN_MAP = "AlreadyLoginMap" 
CONDITION_NOT_IN_TARGET_MAP = "NotInTargetMap" 
CONDITION_IN_TARGET_MAP = "InTargetMap" 
CONDITION_TARGET_NEED_CREATE_TEAM =  "TargetNeedCreateTeam"	
CONDTITION_TARGET_NEEDNT_CREATE_TEAM =  "TargetNeedntCreateTeam"	
CONDITION_HAS_TEAM = "HasTeam" 
CONDITION_HAS_NO_TEAM = "HasNoTeam" 
CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER = "TeamHasMoreThanThreeMember"
CONDITION_TEAM_HAS_LESS_THAN_THREE_MEMBER = "TeamHasLessThanThreeMember"
CONDITION_TEAM_IS_FIGHTING = "TeamIsFighting"
CONDITION_TEAM_IS_NOT_FIGHTING = "TeamIsNotFighting"
CONDITION_IN_FRONT_OF_BOSS = "InFrontOfBoss"
CONDITION_NOT_IN_FRONT_OF_BOSS = "NotInFrontOfBoss"
CONDITION_TEAM_IS_INPLACE_CHECKING = "TeamIsInplaceChecking"
CONDITION_TEAM_IS_NOT_INPLACE_CHECKING = "TeamIsNotInplaceChecking"
CONDITION_TEAM_ALL_MEMBER_READY = "TeamAllMemberReady"
CONDITION_TEAM_NOT_ALL_MEMBER_READY = "TeamNotAllMemberReady"
CONDITION_HAS_NEXT_FIGHT = "HasNextFight"
CONDITION_NOT_HAS_NEXT_FIGHT = "NotHasNextFight"
CONDITION_HAS_ROLL_GAME = "HasRollGame"
CONDITION_NOT_HAS_ROLL_GAME = "NotHasRollGame"
CONDITION_NEXT_FIGHT_IS_STORY = "NextFightIsStory"
CONDITION_NEXT_FIGHT_IS_NOT_STORY = "NextFightIsNotStory"
CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC = "FightFinishMoreThanTenSec"
CONDITION_FIGHT_FINISH_LESS_THAN_TEN_SEC = "FightFinishLessThanTenSec"
CONDITION_FIGHT_FINISH_MORE_THAN_TWENTY_SEC = "FightFinishMoreThanTwentySec"
CONDITION_FIGHT_FINISH_LESS_THAN_TWENTY_SEC = "FightFinishLessThanTwentySec"
CONDITION_AI_HAS_ROLL = "AIHasRoll"
CONDITION_AI_HAS_NOT_ROLL = "AIHasNotRoll"

CONDITION_STATUS_CLEAN = "StatusClean"
CONDITION_STATUS_PREPARE = "StatusPrepare"
CONDITION_STATUS_WAITING = "StatusWaiting"
CONDITION_STATUS_TASKING = "StatusTasking"
CONDITION_OLD_TEAM = "OldTeam"
CONDITION_NOT_OLD_TEAM = "NotOldTeam"
CONDITION_TEAM_HAS_FIVE_MEMBER = "TeamHasFiveMember"
CONDITION_TEAM_NOT_HAS_FIVE_MEMBER = "TeamNotHasFiveMember"
CONDITION_TEAM_HAS_REAL_PLAYER = "TeamHasRealPlayer"
CONDITION_TEAM_NOT_HAS_REAL_PLAYER = "TeamNotHasRealPlayer"
CONDITION_HAS_BEGIN_TASK_TIME = "HasBeginTaskTime"
CONDITION_NOT_HAS_BEGIN_TASK_TIME = "NotHasBeginTaskTime"
CONDITION_TIME_TO_TASK = 'TimeToBeginTask'
CONDITION_NOT_HAS_DEADLINE_TIME = "NotHasDeadlineTime"
CONDITION_TIME_TO_DEAD = "TimeToDead"
CONDITION_AI_IS_LEADER = "AIIsLeader"
CONDITION_AI_IS_MEMBER = "AIIsMember"
CONDITION_BE_KICKED = "BeKicked"
CONDITION_WANT_TO_BE_LEADER = "WantToBeLeader"
CONDITION_WANT_TO_BE_MEMBER = "WantToBeMember"
CONDITION_AI_NOT_AUTOMATCH = "AINotAutoMatch"
CONDITION_AI_NOT_READY = "AINotReady"
CONDITION_TARGET_NOT_FITWITH_GROUP = "TargetNotFitWithGroup"

CONDITION_HAS_PLAYER_PRESENT_ENERGY = "HasPresentEnergy"	-- 有玩家向AI赠送体力
CONDITION_HAS_NO_PLAYER_PRESENT_ENERGY = "HasNoPresent"

CONDITION_HAS_GUILD = "HasGuild"				-- 拥有军团
CONDITION_HAS_NOT_GUILD = "HasNotGuild"				-- 没有军团
CONDITION_NOT_IN_GUILD_MAP = "NotInGuildMap"			-- 不在军团基地中
CONDITION_IN_GUILD_MAP = "InGuildMap"				-- 在军团基地中
GUILD_LEVEL_ENOUGH = "GuildLevelEnough"
CONDITION_GUILD_LEADER = "IsGuildLeader"


CONDITION_NOT_IN_FRONT_OF_BOUNTY_NPC = "NotInFrontOfBountyNpc"
CONDITION_IN_FRONT_OF_BOUNTY_NPC = "InFrontOfBountyNpc"
CONDITION_NOT_HAS_BOUNTY_QUEST = "NotHasBountyQuest"
CONDITION_HAS_BOUNTY_QUEST = "HasBountyQuest"
CONDITION_NOT_MEET_ENEMY = "NotMeetEnemy"
CONDITION_MEET_ENEMY = "MeetEnemy"
CONDITION_FINISH_BOUNTY = "FinishBounty"
CONDITION_NOT_FINISH_BOUNTY = "NotFinishBounty"

CONDITION_FIGHT_MORE_THAN_ONCE = "FightMoreThanOnce"
CONDITION_NOT_FIGHT_MORE_THAN_ONCE = "NotFightMoreThanOnce"

CONDITION_AI_NAME_IS_NUMBER = "AINameIsNumber"
CONDITION_AI_NAME_IS_NOT_NUMBER = "AINameIsNotNumber"

CONDITION_LAST_FIGHT_FAIL = "LastFightFail"
CONDITION_LAST_FIGHT_WIN = "LastFightWin"
CONDITION_NOT_HAS_LAST_FIGHT = "NotHasLastFight"
CONDITION_HAS_KICK_AI = "HasKickAI"
CONDITION_NOT_HAS_KICK_AI = "NotHasKickAI"
CONDITION_HAS_DISSOLVE_TEAM_TIME_LINE = "HasDissolveTeamTimeLine"
CONDITION_NOT_HAS_DISSOLVE_TEAM_TIME_LINE = "NotHasDissolveTeamTimeLine"
CONDITION_TIME_TO_DISSOLVE = "TimeToDissolve"
CONDITION_NOT_TIME_TO_DISSOLVE = "NotTimeToDissolve"
CONDITION_HAS_SHOUT_TIME_LINE = "HasShoutTimeLine"
CONDITION_NOT_HAS_SHOUT_TIME_LINE = "NotHasShoutTimeLine"
CONDITION_TIME_TO_SHOUT = "TimeToShout"
CONDITION_NOT_TIME_TO_SHOUT = "NotTimeToShout"
CONDITION_TEAM_INPLACE_CHECKING_OUT_OF_TIME = "TeamInplaceCheckingOutOfTime"
CONDITION_TEAM_INPLACE_CHECKING_NOT_OUT_OF_TIME = "TeamInplaceCheckingNotOutOfTime"
CONDITION_SOMEONE_NOT_READY = "SomeOneNotReady"
CONDITION_NOONE_NOT_READY = "NoOneNotReady"
CONDITION_HAS_KICK_UNACTIVE_MEMBER = "HasKickUnactiveMember"
CONDITION_NOT_HAS_KICK_UNACTIVE_MEMBER = "NotHasKickUnactiveMember"
CONDITION_IN_FRONT_OF_NPC = "InFrontOfBountyNpc"
CONDITION_NOT_IN_FRONT_OF_NPC = "NotInFrontOfBountyNpc"
CONDITION_IN_BOSS_MAP = "InBossMap"
CONDITION_NOT_IN_BOSS_MAP = "NotInBossMap"
CONDITION_TEAM_NOT_AUTOCONFIRM_OR_NOT_AUTOMATCH = "TeamNotAutoConfirmOrNotAutoMatch"
CONDITION_TEAM_IS_AUTOCONFIRM_OR_NOT_AUTOMATCH = "TeamIsAutoConfirmOrNotAutoMatch"

CONDITION_NOT_IN_FREE_MOVE_MAP_POS = "NotInFreeMoveMapPos"
CONDITION_IN_FREE_MOVE_MAP_POS = "InFreeMoveMapPos"

CONDITION_IN_FREE_MOVE_MAP_TOO_LONG = "InFreeMoveMapTooLong"
CONDITION_IN_FREE_MOVE_MAP_NOT_TOO_LONG = "InFreeMoveMapNotTooLong"
CONDITION_NOT_ENTER_FREE_MOVE_MAP = "NotEnterFreeMoveMap"
CONDITION_HAS_ENTER_FREE_MOVE_MAP = "HasEnterFreeMoveMap"

CONDITION_NOT_HAS_NEXT_STEP = "NotHasNextStep"
CONDITION_HAS_NEXT_STEP = "HasNextStep"
CONDITION_HAS_VOTE = "HasVote"
CONDITION_NOT_HAS_VOTE = "NotHasVote"

CONDITION_AI_LEVEL_ENOUGH = "AILevelEnough"
CONDITION_AI_LEVEL_NOT_ENOUGH = "AILevelNotEnough"

CONDITION_HAS_JOIN_REQUEST = "HasJoinRequest"
CONDITION_NOT_HAS_JOIN_REQUEST = "NotHasJoinRequest"

CONDITION_FINISH_MOVE_WITHOUT_REAL_PLAYER = "FinishMoveWithOutRealPlayer"
CONDITION_NOT_FINISH_MOVE_WITHOUT_REAL_PLAYER = "NotFinishMoveWithOutRealPlayer"

CONDITION_NEED_TO_INPLACE_READY = "NeedToInplaceReady"

CONDITION_TODAY_HAS_CHANGE_HEAD = "TodayHasChangeHead"
CONDITION_TODAY_NOT_HAS_CHANGE_HEAD = "TodayNotHasChangeHead"

CONDITION_SLEEP_TOOLONG = "SleepTooLong"

CONDITION_NOT_HAS_DISSOLVE_TIME_LINE_WHEN_ALL_AI = "NotHasDissolveTimeLineWhenAllAI"
CONDITION_TIME_TO_DISSOLVE_WHEN_ALL_AI = "TimeToDissolveWhenAllAI"

CONDITION_BATTLE_END = "BattleEnd"
CONDITION_BATTLE_NOT_END = "BattleNotEnd"

condition_cfg = {}
target_type_cfg = {}
priority_cfg = {}

local logic_for_team_fight = 
{
	{condition = {CONDITION_SLEEP_TOOLONG}, action = "LogoutAndFinish", log = "sleeptoolong"},
	{condition = {CONDITION_TARGET_NOT_FITWITH_GROUP}, action = "Logout"},
	{condition = {CONDITION_BE_KICKED}, action = "Logout"},

	-- STATUS_CLEAN
	{condition = {CONDITION_STATUS_CLEAN,CONDITION_HAS_TEAM, CONDITION_TEAM_OLD_TEAM}, action = "CleanOldData"},
	{condition = {CONDITION_STATUS_CLEAN,CONDITION_NOT_HAS_TEAM}, action = "ChangeStatusToPrepare"},

	--当队伍人数小于两人且等待时间大于20min，解散队伍
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_LESS_THAN_THREE_MEMBER, CONDITION_NOT_HAS_DISSOLVE_TEAM_TIME_LINE}, action = "SetDissolveTimeline"},
	{condition = {CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_HAS_DISSOLVE_TEAM_TIME_LINE}, action = "ClearDissolveTimeline"},
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_LESS_THAN_THREE_MEMBER, CONDITION_HAS_DISSOLVE_TEAM_TIME_LINE, CONDITION_TIME_TO_DISSOLVE}, action = "DissolveTeamAndLogout"},

	--当副本结束时，解散队伍
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_BATTLE_END}, action = "DissolveTeamAndLogout"},
	
	-- STATUS_PREPARE
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_NOT_LOGIN_MAP},  action = 'LoginMap'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_NOT_IN_TARGET_MAP},  action = 'EnterMap'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'CreateTeam'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_WANT_TO_BE_MEMBER, CONDITION_HAS_NO_TEAM, CONDITION_AI_NOT_AUTOMATCH},  action = 'AIAutoMatch'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_HAS_TEAM},  action = 'ChangeStatusToWaiting'},

	--处理入队申请	
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_JOIN_REQUEST},  action = 'ProcessJoinRequest'},

	-- STATUS_WAITING
	{condition = {CONDITION_STATUS_WAITING, CONDITION_NOT_FIGHT_MORE_THAN_ONCE, CONDITION_NOT_HAS_NEXT_FIGHT},  action = 'LeaveTeamAndReAutoMatch'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_FIGHT_MORE_THAN_ONCE, CONDITION_NOT_HAS_NEXT_FIGHT, CONDITION_NOT_HAS_ROLL_GAME},  action = 'LogoutAndFinish',  log = ""},

	-- STATUS_WAITING   MODE_LEADER
	{condition = {CONDITION_STATUS_WAITING, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},   --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_AUTOCONFIRM_OR_NOT_AUTOMATCH, CONDITION_HAS_NEXT_FIGHT}, action = 'SetTeamAutoConfirmAndAutoMatch'}, 
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER},  action = 'BeginTask'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_NOT_HAS_DISSOLVE_TIME_LINE_WHEN_ALL_AI},  action = 'SetTeamDissolveTimelineWhenAllMemberIsAI'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_TIME_TO_DISSOLVE_WHEN_ALL_AI},  action = 'DissolveTeamAndPrepare'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NOT_HAS_BEGIN_TASK_TIME},  action = 'SetBeginTaskTime'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TIME_TO_TASK},  action = 'BeginTask'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_HAS_SHOUT_TIME_LINE}, action = "CancelShoutTimeLine"},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_NOT_HAS_SHOUT_TIME_LINE}, action = "SetShoutTimeLine", asleep = true},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_HAS_SHOUT_TIME_LINE, CONDITION_TIME_TO_SHOUT, CONDITION_TEAM_IS_NOT_FIGHTING}, action = "ShoutInWorld", asleep = true},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_IN_TARGET_MAP},  action = 'Move', asleep = true},

	-- STATUS_WAITING MODE_MEMBER
	{condition = {CONDITION_STATUS_WAITING, CONDITION_WANT_TO_BE_MEMBER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},  --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_FIGHT_MORE_THAN_ONCE, CONDITION_NOT_HAS_NEXT_FIGHT, CONDITION_NOT_HAS_ROLL_GAME},  action = 'LogoutAndFinish'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_ROLL_GAME},  action = 'Roll'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_HAS_NO_TEAM}, action = "Move", asleep = true},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_TEAM_IS_NOT_FIGHTING}, action = "DoNothing", asleep = true},

	-- STATUS_TASKING MODE_MEMBER  如果玩家发起投票想成为队长，可能会进入这个状态
	{condition = {CONDITION_STATUS_TASKING, CONDITION_WANT_TO_BE_MEMBER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},  --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_FIGHT_MORE_THAN_ONCE, CONDITION_NOT_HAS_NEXT_FIGHT, CONDITION_NOT_HAS_ROLL_GAME},  action = 'LogoutAndFinish'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_ROLL_GAME},  action = 'Roll'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_TEAM_IS_NOT_FIGHTING},  action = 'DoNothing', asleep = true},

	-- STATUS_TASKING   MODE_LEADER
	{condition = {CONDITION_STATUS_TASKING, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},  --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_AUTOCONFIRM_OR_NOT_AUTOMATCH, CONDITION_HAS_NEXT_FIGHT}, action = 'SetTeamAutoConfirmAndAutoMatch'}, 
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NOT_IN_FRONT_OF_NPC, CONDITION_NOT_IN_BOSS_MAP},  action = 'MoveToNpc'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_NOT_HAS_DEADLINE_TIME}, action = "SetDeadlineTime"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_TIME_TO_DEAD, CONDITION_NOT_HAS_ROLL_GAME}, action = "LogoutAndFinish"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_FIGHT_MORE_THAN_ONCE, CONDITION_NOT_HAS_NEXT_FIGHT, CONDITION_NOT_HAS_ROLL_GAME},  action = 'LogoutAndFinish'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_ROLL_GAME, CONDITION_AI_HAS_NOT_ROLL},  action = 'Roll'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_NOT_IN_FRONT_OF_BOSS, CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC},  action = 'MoveToBoss'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NEXT_FIGHT_IS_STORY, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_IN_FRONT_OF_BOSS, CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC, CONDITION_NOT_HAS_ROLL_GAME},  action = 'FindNpc'},


	--踢人
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_NEXT_FIGHT, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_TEAM_INPLACE_CHECKING_OUT_OF_TIME, CONDITION_SOMEONE_NOT_READY, CONDITION_NOT_HAS_KICK_UNACTIVE_MEMBER}, action = "KickUnactiveMember"},

	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_NOT_HAS_LAST_FIGHT, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_IN_FRONT_OF_BOSS, CONDITION_TEAM_IS_NOT_INPLACE_CHECKING, CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC, CONDITION_NOT_HAS_ROLL_GAME},  action = 'InplaceCheck'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_LAST_FIGHT_FAIL, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_IN_FRONT_OF_BOSS, CONDITION_TEAM_IS_NOT_INPLACE_CHECKING, CONDITION_FIGHT_FINISH_MORE_THAN_TWENTY_SEC, CONDITION_NOT_HAS_ROLL_GAME},  action = 'InplaceCheck', log = "fightfail"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_LAST_FIGHT_WIN, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_IN_FRONT_OF_BOSS, CONDITION_TEAM_IS_NOT_INPLACE_CHECKING, CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC, CONDITION_NOT_HAS_ROLL_GAME},  action = 'InplaceCheck'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_ALL_MEMBER_READY, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_IN_FRONT_OF_BOSS, CONDITION_FIGHT_FINISH_MORE_THAN_TEN_SEC, CONDITION_NOT_HAS_ROLL_GAME},  action = 'StartFight'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_HAS_SHOUT_TIME_LINE}, action = "CancelShoutTimeLine"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_NOT_HAS_SHOUT_TIME_LINE}, action = "SetShoutTimeLine", asleep = true},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_HAS_SHOUT_TIME_LINE, CONDITION_TIME_TO_SHOUT, CONDITION_TEAM_IS_NOT_FIGHTING}, action = "ShoutInWorld", asleep = true},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_IS_NOT_FIGHTING},  action = 'DoNothing', asleep = true},
}

local logic_for_bounty =  
{
	{condition = {CONDITION_SLEEP_TOOLONG}, action = "LogoutAndFinish", log = "sleeptoolong"},
	{condition = {CONDITION_TARGET_NOT_FITWITH_GROUP}, action = "Logout"},
	{condition = {CONDITION_BE_KICKED}, action = "Logout"},

	-- STATUS_CLEAN
	{condition = {CONDITION_STATUS_CLEAN,CONDITION_HAS_TEAM, CONDITION_TEAM_OLD_TEAM}, action = "CleanOldData"},
	{condition = {CONDITION_STATUS_CLEAN,CONDITION_NOT_HAS_TEAM}, action = "ChangeStatusToPrepare"},

	--当队伍人数小于两人且等待时间大于20min，解散队伍
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_LESS_THAN_THREE_MEMBER, CONDITION_NOT_HAS_DISSOLVE_TEAM_TIME_LINE}, action = "SetDissolveTimeline"},
	{condition = {CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_HAS_DISSOLVE_TEAM_TIME_LINE}, action = "ClearDissolveTimeline"},
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_TEAM, CONDITION_TEAM_HAS_LESS_THAN_THREE_MEMBER, CONDITION_HAS_DISSOLVE_TEAM_TIME_LINE, CONDITION_TIME_TO_DISSOLVE}, action = "DissolveTeamAndLogout"},

	-- STATUS_PREPARE
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_NOT_LOGIN_MAP},  action = 'LoginMap'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_NOT_IN_TARGET_MAP},  action = 'EnterMap'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'CreateTeam'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_WANT_TO_BE_MEMBER, CONDITION_HAS_NO_TEAM, CONDITION_AI_NOT_AUTOMATCH},  action = 'AIAutoMatch'},
	{condition = {CONDITION_STATUS_PREPARE, CONDITION_HAS_TEAM},  action = 'ChangeStatusToWaiting'},

	--处理入队申请	
	{condition = {CONDITION_AI_IS_LEADER, CONDITION_HAS_JOIN_REQUEST},  action = 'ProcessJoinRequest'},

	-- STATUS_WAITING   MODE_LEADER
	{condition = {CONDITION_STATUS_WAITING, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},  --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_AUTOCONFIRM_OR_NOT_AUTOMATCH, CONDITION_NOT_FINISH_BOUNTY}, action = 'SetTeamAutoConfirmAndAutoMatch'}, 
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER},  action = 'BeginTask'},
	--{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER},  action = 'DissolveTeamAndPrepare'},
	--{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NOT_HAS_BEGIN_TASK_TIME},  action = 'SetBeginTaskTime'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_NOT_HAS_BEGIN_TASK_TIME},  action = 'SetBeginTaskTime'},
	--{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TIME_TO_TASK},  action = 'BeginTask'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TIME_TO_TASK},  action = 'BeginTask'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_LEADER, CONDITION_IN_TARGET_MAP},  action = 'Move', asleep = true},

	-- STATUS_WAITING MODE_MEMBER
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_FINISH_BOUNTY}, action = "LogoutAndFinish"},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_HAS_NO_TEAM}, action = "Move", asleep = true},
	{condition = {CONDITION_STATUS_WAITING, CONDITION_AI_IS_MEMBER, CONDITION_TEAM_IS_NOT_FIGHTING}, action = "DoNothing", asleep = true},

	-- STATUS_TASKING MODE_MEMBER 如果玩家发起投票想成为队长，可能会进入这个状态
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_FINISH_BOUNTY}, action = "LogoutAndFinish"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_NEED_TO_INPLACE_READY},  action = 'InplaceReady'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_HAS_NO_TEAM}, action = "Move", asleep = true},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_MEMBER, CONDITION_TEAM_IS_NOT_FIGHTING}, action = "DoNothing", asleep = true},

	-- STATUS_TASKING MODE_LEADER
	{condition = {CONDITION_STATUS_TASKING, CONDITION_WANT_TO_BE_LEADER, CONDITION_HAS_NO_TEAM},  action = 'Logout'},  --fight 或者 ai 服务重启时会解散队长为ai的队伍，此为特殊处理
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_HAS_VOTE},  action = 'Vote'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_FINISH_BOUNTY}, action = "ChangeLeaderAndLogout"},--"LogoutAndFinish"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_FIVE_MEMBER, CONDITION_TEAM_NOT_AUTOCONFIRM_OR_NOT_AUTOMATCH, CONDITION_NOT_FINISH_BOUNTY}, action = 'SetTeamAutoConfirmAndAutoMatch'}, 
	--{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NOT_HAS_BOUNTY_QUEST, CONDITION_NOT_IN_FRONT_OF_BOUNTY_NPC},  action = 'MoveToBountyNpc'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_NOT_HAS_BOUNTY_QUEST, CONDITION_NOT_IN_FRONT_OF_BOUNTY_NPC},  action = 'MoveToBountyNpc'},
	--{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_NOT_HAS_BOUNTY_QUEST, CONDITION_IN_FRONT_OF_BOUNTY_NPC, },  action = 'StartBountyQuest'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_NOT_HAS_BOUNTY_QUEST, CONDITION_IN_FRONT_OF_BOUNTY_NPC, },  action = 'StartBountyQuest'},
	--{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_TEAM_HAS_FIVE_MEMBER}, action = "DissolveTeamAndLogout"},
	--{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_LAST_FIGHT_FAIL, CONDITION_NOT_HAS_KICK_AI}, action = "KickAIMember"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_HAS_BOUNTY_QUEST, CONDITION_NOT_FINISH_BOUNTY, CONDITION_NOT_MEET_ENEMY, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_NOT_HAS_KICK_AI}, action = "MoveInBountyMap"},
	--{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_HAS_BOUNTY_QUEST, CONDITION_NOT_FINISH_BOUNTY, CONDITION_NOT_MEET_ENEMY, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_HAS_KICK_AI}, action = "MoveInBountyMapBySmallStep"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_HAS_REAL_PLAYER, CONDITION_TEAM_HAS_MORE_THAN_THREE_MEMBER, CONDITION_HAS_BOUNTY_QUEST, CONDITION_NOT_FINISH_BOUNTY, CONDITION_MEET_ENEMY, CONDITION_TEAM_IS_NOT_FIGHTING, CONDITION_NOT_HAS_KICK_AI}, action = "StartBountyFight"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_NOT_FINISH_MOVE_WITHOUT_REAL_PLAYER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER}, action = "MoveInBountyMapWithOutRealMan"},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_NOT_HAS_REAL_PLAYER, CONDITION_FINISH_MOVE_WITHOUT_REAL_PLAYER},  action = 'DissolveTeamAndCleanBountyInfoAndPrepare'},
	{condition = {CONDITION_STATUS_TASKING, CONDITION_AI_IS_LEADER, CONDITION_TEAM_IS_NOT_FIGHTING},  action = 'DoNothing', asleep = true},
}

function LoadConditionConfigForTeamFight(battle_id)
	condition_cfg[battle_id] = logic_for_team_fight
	target_type_cfg[battle_id] = "team_fight"
	priority_cfg[battle_id] = 3 
end

function LoadConditionConfigForBounty(activity_id)
	condition_cfg[activity_id] = logic_for_bounty
	target_type_cfg[activity_id] = "bounty"
	priority_cfg[activity_id] = 3 
end

function GetTargetType(target)
	return target_type_cfg[target]
end

condition_cfg[TARGET_FRIEND] = 
{
	{ condition = { CONDITION_HAS_PLAYER_PRESENT_ENERGY }, action = "AddFriend" },
	{ condition = { CONDITION_HAS_NO_PLAYER_PRESENT_ENERGY }, action = "FinishTargetFriend" }
}
target_type_cfg[TARGET_FRIEND] = "friend"
priority_cfg[TARGET_FRIEND] = 3 

condition_cfg[TARGET_GUILD] = 
{
	{ condition = { GUILD_LEVEL_ENOUGH, CONDITION_HAS_NOT_GUILD }, action = "ApplyGuild" },
	{ condition = { CONDITION_HAS_GUILD, CONDITION_NOT_IN_GUILD_MAP }, action = "EnterGuildMap" },
	{ condition = { CONDITION_HAS_GUILD, CONDITION_IN_GUILD_MAP }, action = "DoGuildWork" },
	{ condition = { CONDITION_HAS_GUILD, CONDITION_IN_GUILD_MAP, CONDITION_GUILD_LEADER }, action = "DoLeaderWork"},
}
target_type_cfg[TARGET_GUILD] = "guild"
priority_cfg[TARGET_GUILD] = 3 

condition_cfg[TARGET_CHANGE_NAME] = 
{
	{ condition = { CONDITION_TODAY_NOT_HAS_CHANGE_HEAD}, action = "ChangeHead"},
	{ condition = { CONDITION_AI_LEVEL_ENOUGH, CONDITION_AI_NAME_IS_NUMBER}, action = "ChangeName"},
	{ condition = { CONDITION_AI_LEVEL_NOT_ENOUGH, CONDITION_AI_NAME_IS_NUMBER}, action = "FinishChangeName"},
	{ condition = { CONDITION_AI_NAME_IS_NOT_NUMBER}, action = "FinishChangeName"},
}
target_type_cfg[TARGET_CHANGE_NAME] = "change_name"
priority_cfg[TARGET_CHANGE_NAME] = 1 

condition_cfg[TARGET_FREE_MOVE] = 
{
	{condition = {CONDITION_NOT_LOGIN_MAP},  action = 'LoginMap'},
	{condition = {CONDITION_NOT_ENTER_FREE_MOVE_MAP},  action = 'EnterFreeMoveMap'},
	{condition = {CONDITION_IN_FREE_MOVE_MAP_TOO_LONG},  action = 'LogoutAndFinish'},
}
target_type_cfg[TARGET_FREE_MOVE] = "free_move"
priority_cfg[TARGET_FREE_MOVE] = 3 

condition_cfg[TARGET_MAIN_QUEST] = 
{
	{condition = {CONDITION_HAS_NEXT_STEP}, action = "DoNextQuest"},
	{condition = {CONDITION_NOT_HAS_NEXT_STEP}, action = "LogoutAndFinish"},
}
target_type_cfg[TARGET_MAIN_QUEST] = "main_quest"
priority_cfg[TARGET_MAIN_QUEST] = 2
